//**********************************************************************
// PalindromeTester.java  Java Foundations
//
// Demonstrates the use of nexted while loops.
//**********************************************************************

import java.util.Scanner;

public class PalindromTester
{
  //-----------------------------------------------------
  // Tests string to see if they are palindrome.
  //-----------------------------------------------------
  public static void main (String[] args)
  {
    String str,another = "y";
    int left,right;

    Scanner scan = new Scanner (System.in);
    str = scan.nextLine();
    while (another.equalsIgnoreCase("y")) // allows y orY
    {
      System.out.println ("Enter a potential palindrome: ");

      left = 0;
      right = str.length() - 1;
  
      while (str.charAt(left) == str.charAt(right) && left < right)
      {
        left++;
        right--;
      }
      System.out.println();
      if (left < right)
         System.out.println ("Taht string is NOT a palidrome.");
      else
         System.out.println ("That string IS a palindrome.");
         System.out.println ();
         System.out.println ("Test another palindrome (y/n)? ");
         another = scan.nextLine();
     }
  
  }
}


